package com.uenpay.im.ui.old.activity.red;

import com.qiyunxin.android.http.net.HttpInvokeItem;
import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;

import org.json.JSONException;
import org.json.JSONObject;

public class SendRedInvokItem extends HttpInvokeItem {

	public class SendRedInvokItemResult extends HttpInvokeResult {
	}

	public SendRedInvokItemResult getOutput() {
		return (SendRedInvokItemResult) GetResultObject();
	}

	public SendRedInvokItem(String packetsid, String tagetid, int tagettype) {
		// http://api.aitiapp.com/RedPackets/sendPackets?packetsid=&tagetid=&tagettype=
		String url = APIConfiguration.getBaseUrl()
				+ "Purse/RedPackets/sendPackets?packetsid=" + packetsid + "&tagetid="
				+ tagetid + "&tagettype=" + tagettype + "&"
				+ APIConfiguration.getCustIdAndToken();
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) {
		SendRedInvokItemResult result = new SendRedInvokItemResult();
		try {
			JSONObject json = new JSONObject(responseBody);
			result.status = json.optInt("status");
			result.msg = json.optString("msg");
			JSONObject jsonObject = json.optJSONObject("data");
			if (jsonObject == null) {
				return result;
			}
		} catch (JSONException e) {
			e.printStackTrace();
			return result;
		}

		return result;
	}

}
